<template>
  <div class="dvfull_container">
    <div class="sub-header">
      <div class="station-name position-common">
        {{ isCenter ? "深圳地铁12号线" : deptName || stationName }}
      </div>
      <div class="date-now position-common"><Timebox /></div>

      <div class="pro-title position-common" v-if="isCenter">
        <div class="pro-title-logo"></div>
        <span>12号线能源管理系统</span>
      </div>

      <div class="pro-title position-common" v-else>
        <div class="pro-title-logo"></div>
        <span>{{ deptName || stationName }}能源管理系统</span>
      </div>
    </div>

    <!-- 左侧线路和车站级菜单切换 -->
    <CenterSide v-if="isCenter"></CenterSide>
    <Side v-else></Side>

    <router-view v-if="isLogin"></router-view>

    <!-- 底部车站导航 -->
    <div class="bg bg-blur" v-show="showStList"></div>
    <div class="station-list" v-show="showStList">
      <div class="line"></div>
      <div class="closed-icon" @click="setClose">
        <i class="el-icon-circle-close"></i>
      </div>
      <div class="list-item-box">
        <div
          class="item-station"
          v-for="(item, index) in stationList"
          :key="index"
        >
          <div
            @click="selectStation(item.stationName, item.dockingCode)"
            class="station-name-list"
            :class="{ txtcolor: stationName === item.stationName }"
          >
            {{ item.stationName }}
          </div>
          <span
            class="icon-color"
            :class="{ bgcolor: stationName === item.stationName }"
            @click="selectStation(item.stationName, item.dockingCode)"
          ></span>
        </div>
      </div>
    </div>

    <!-- 右侧回退按钮 -->
    <div class="rgo-back" @click="back">
      <div class="r-g">返回</div>
      <div class="r-g-line"></div>
      <div class="r-g">退出</div>
    </div>
  </div>
</template>

<script>
import { logout } from "../api/base8012.js";
import Side from "../components/side/Side";
import CenterSide from "../components/side/CenterSide";
import Timebox from "../components/timebox/index";
import { mapState } from "vuex";
export default {
  components: {
    Side,
    CenterSide,
    Timebox,
  },
  data() {
    return {
      isLogin: sessionStorage.getItem("token_12"),
    };
  },
  mounted() {
    setTimeout(() => {
      this.isLogin = sessionStorage.getItem("token_12");
    }, 1234);
  },
  methods: {
    setClose() {
      this.$store.commit("SET_SHOW", false);
    },
    //站点切换
    selectStation(stationName, stationCode) {
      sessionStorage.setItem("detailId", stationCode);
      this.$store.commit("SET_STATIONNAME", stationName);
      this.$store.commit("SET_STATIONID", stationCode);
    },
    // 返回并退出
    back() {
      if (this.isLink) {
        window.close();
      } else {
        logout().then((res) => {
          if (res.code == 0) {
            this.$store.commit("SET_STATIONNAME", "左炮台东");
            this.$store.commit("SET_DEPTNAME", "");
            this.$store.commit("SET_SHOW", false);
            this.$store.commit("SET_ISLINK", false);
            this.$store.commit("SET_STATIONID", "");
            sessionStorage.clear();
            this.$router.replace("/login");
          } else {
            this.$message.error(res.message);
          }
        });
      }
    },
  },
  computed: {
    ...mapState([
      "showStList",
      "isCenter",
      "stationName",
      "stationList",
      "stationCode",
      "deptName",
      "username",
      "isLink",
    ]),
  },
};
</script>

<style lang="less" scoped>
.dvfull_container {
  width: 100%;
  height: 100%;
  background-color: #03091c;
}
.sub-header {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 2;
  width: 100%;
  margin: 0 auto;
  height: 80px;
  background: url("../assets/img/top-nav.png") no-repeat center;
  background-size: 100% 100%;

  .position-common {
    position: absolute;
    top: 0;
    line-height: 60px;
    height: 72px;
    font-weight: bold;
    text-align: center;
  }
  .station-name {
    width: 230px;
    left: 0;
    background: url("../assets/img/location.png") no-repeat center center;
    background-size: 100% 100%;
    font-size: 22px;
    color: #fefefe;
    padding-right: 40px;
  }

  .date-now {
    left: 240px;
    width: 248px;
    font-size: 16px;
    color: #ffffff;
  }
  .weather-now {
    left: 480px;
    width: 248px;
    font-size: 16px;
    color: #ffffff;
  }
  .pro-title {
    cursor: pointer;
    font-size: 24px;
    width: 480px;
    left: 50%;
    transform: translateX(-50%);
    color: #fcfcfc;
    text-shadow: 5px 5px 0px #010e19, 4px 4px 0px #010e19;
    display: flex;
    align-items: center;
    justify-content: center;
    .pro-title-logo {
      width: 105.6px;
      height: 27px;
      line-height: 27px;
      background-color: #fff;
      margin-top: 5px;
      margin-right: 8px;
      background: url("../assets/img/logo.png") no-repeat bottom center;
      background-size: contain;
    }
  }
  .nav-splace {
    right: 2%;
    font-size: 16px;
    color: #fefefe;
  }
}

.station-list {
  position: fixed;
  color: #fff;
  z-index: 666;
  bottom: 2%;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  height: 120px;
  background: linear-gradient(0deg, #082d5a, #196281);
  box-shadow: 2px 0px 9px 0px #03091b, 0px 3px 18px 0px rgba(0, 198, 255, 0.61);
  opacity: 0.8;
  border-radius: 10px;
  .closed-icon {
    // background-color: #fff;
    width: 30px;
    height: 30px;
    z-index: 6;
    position: absolute;
    top: 0;
    cursor: pointer;
    left: 0;
    i {
      width: 30px;
      height: 30px;
      z-index: 6;
      position: absolute;
      top: 0;
      cursor: pointer;
      left: 0;
      font-size: 24px;
    }
  }
  .line {
    width: 1860px;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    height: 2px;
    border: 1px dashed #0271b5;
    border-radius: 1px;
  }
  .list-item-box {
    width: 100%;
    height: 100%;
    display: flex;
    // background-color: #3fb29a;
    .item-station {
      width: 100%;
      height: 100%;
      margin: 0 2px;
      // background-color: #faff05;
      position: relative;
      &:nth-child(2n) {
        div {
          top: 0;
          left: 0;
        }
        // background-color: chartreuse;
      }
      &:nth-child(2n-1) {
        div {
          bottom: 0;
          left: 0;
        }
        // background-color: salmon;
      }
      .station-name-list {
        width: 100%;
        height: 50%;
        cursor: pointer;
        // overflow: hidden;
        text-align: center;
        position: absolute;
        // line-height: 0.75rem;
        padding-top: 20px;
        color: #28c2ff;
        font-size: 10px;
      }
      .icon-color {
        position: absolute;
        top: 50%;
        left: 50%;
        cursor: pointer;
        transform: translate(-50%, -50%);
        z-index: 55;
        width: 15px;
        height: 15px;
        border-radius: 50%;
        background-color: #1b86c9;
      }
      .txtcolor {
        color: #faff05;
      }
      .bgcolor {
        background-color: #faff05;
      }
    }
  }
}
.bg-blur {
  position: fixed;
  z-index: 66;
  background: rgba(235, 242, 245, 0.2);
  bottom: 2%;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  height: 120px;
  background-repeat: no-repeat;
  background-position: center;
  background-size: cover;
  -webkit-filter: blur(10px);
  -moz-filter: blur(10px);
  -o-filter: blur(10px);
  -ms-filter: blur(10px);
  filter: blur(10px);
}
.rgo-back {
  position: absolute;
  top: 50%;
  right: 0;
  width: 40px;
  height: 300px;
  transform: translateY(-50%);
  background-color: #fff;
  background: url("../assets/img/rgo.png") no-repeat center center;
  background-size: cover;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  font-size: 14px;
  color: #84bfdd;
  z-index: 666;
  cursor: pointer;
  .r-g {
    width: 40px;
    writing-mode: vertical-lr;
    letter-spacing: 8px;
    line-height: 40px;
  }
  .r-g-line {
    width: 20px;
    height: 1px;
    background: #84bfdd;
    margin: 10px auto;
  }
}
</style>
